Ext.Loader.setConfig({enabled: true});
Ext.Loader.setPath('Ext.ux', '../extjs/examples/ux');
Ext.require([
    'Ext.form.Panel',
    'Ext.ux.form.MultiSelect',
    'Ext.ux.form.ItemSelector',
    'Ext.tip.QuickTipManager',
    'Ext.ux.ajax.JsonSimlet',
    'Ext.ux.ajax.SimManager',
    'Ext.ux.form.SearchField'
]);

Ext.application({
    requires: ['Ext.container.Viewport'],
    name: 'AM',
    appFolder: 'app',
    controllers: [
                  'Users'
              ],

    launch: function() {
    	
    	Ext.ux.ajax.SimManager.init({
    	    delay: 300,
    	    defaultSimlet: null
    	}).register({
    	    'Numbers': {
    	    	data: [
    	               [1,'RESERVE_PERMISSION'],
    	               [2, 'MANAGE_FRAUD_PERMISSION'],
    	               [3, 'MANAGE_MERCHANT'],
    	               [4, 'GENERATE_ORDERNUMBER'],
    	               [5, 'MANAGE_WORK_AND_REST_DAY'],
    	               [6, 'MANAGE_SABRE_TICKET_PRINTER'],
    	               [7, 'EDIT_AIRPORT'],
    	               [8, 'SMS_MONITORING'],
    	               [9, 'REFUND_PERMISSION'],
    	               [10, 'DEPOSIT_PERMISSION']
    	            ],
    	        stype: 'json'
    	    }
    	});
    	
    	permissionStore = Ext.create('Ext.data.ArrayStore', {
            fields: ['value','text'],
            proxy: {
                type: 'ajax',
                url: 'Numbers',
                reader: 'array'
            },
            autoLoad: true
        });
    	
    	
    	Ext.create('Ext.container.Viewport', {
            layout: 'border',
            items: [
            {
                // xtype: 'panel' implied by default
                //title: 'West Region is collapsible',
                region:'west',
                xtype: 'panel',
                margins: '5 0 0 5',
                width: 300,
                collapsible: false,   // make collapsible
                id: 'west-region-container',
                layout: 'anchor',
                
                dockedItems: [{
                    xtype: 'toolbar',
                    dock: 'top',
                    items: [{
                        xtype: 'label',
                        forId: 'myFieldId',
                        text: 'Search',
                        margin: '0 0 0 10'
                    },{
                        xtype: 'textfield',
                        hideLabel: true,
                        flex: 1
                    }, {
                        xtype:'button',
                        text: 'Search',
                        iconCls : 'search',
                        iconMask : true
                    }]
                }],
                
                items: [{
                	xtype:'panel',
                	layout:'fit',
                	frame: true,
                	items: [{
                    	xtype:'button',
                    	id:'newUserBtn',
                    	action:'resetUserForm',
                    	text:'New User',
                    	iconCls: 'add',
                        iconAlign: 'left'
                    }]
                },{
                	xtype:'panel',
                	items:[{
                		xtype:'userList'
                	}]
                }
                        
                ]
            
            },{
                title: 'New User',
                region: 'center',     // center region is required, no width/height specified
                xtype: 'panel',
                layout: 'fit',
                margins: '5 5 0 0',
                items:[{
                	xtype:'useredit'
                }
                       
                ]
            }]
        });
    	
    	
    	
    	
    	
    	
    }

});